apiready = function() {
	$api.getServerUrl(function(serverUrl) {
		//获取首页广告
		$api.do_get('/api/home/adv', function(result) {
			result.forEach(function(item) {
				item.img = serverUrl + item.img;
			});
			$api.crateDom("_homeAd.html", result, function(resultHtml) {
				document.getElementById('homeAd').innerHTML = resultHtml;
				TouchSlide({
					slideCell: "#slideBox",
					titCell: ".hd ul", //开启自动分页 autoPage:true ，此时设置 titCell 为导航元素包裹层
					mainCell: ".bd ul",
					effect: "leftLoop",
					autoPage: true, //自动分页
					autoPlay: true //自动播放
				});
			});
		});

		//获取拼团信息
		$api.do_get('/api/home/pt', function(result) {
			result.forEach(function(item) {
				item.sgImg = serverUrl + item.sgImg;
			});
			$api.crateDom("_homeGroup.html", result, function(resultHtml) {
				document.getElementById('tuanList').innerHTML = resultHtml;
			});
		});

		//获取经纪人信息
		$api.do_get('/api/home/jjr', function(result) {
			result.forEach(function(item) {
				item.img = serverUrl + item.img;
				$api.log(item.img);
			});
			$api.crateDom("_homeJjr.html", result, function(resultHtml) {
				document.getElementById('jjr').innerHTML = resultHtml;
			});
		});

		//获取福利信息
		$api.do_get('/api/home/fl', function(result) {
			result.forEach(function(item) {
				item.img = serverUrl + item.img;
			});
			$api.crateDom("_homeFl.html", result, function(resultHtml) {
				document.getElementById('fl').innerHTML = resultHtml;
			});
		});
	});
};

function adOpenWin(winName, winUrl) {
	var name = winName.split('/')[2];
	var url = winUrl.split('/')[2];
	// $api.log(winName+" "+winUrl);
	$api.mOpenWin("ad" + name, url + ".html");
}

function adAdOpenWin(winName, winUrl) {
	// $api.log(winName+" "+winUrl);
	$api.mOpenWin(winUrl, winUrl);
}

function openJiaZhuang() {
	$api.getUserInf(function(user) {
		if (user) {
			$api.mOpenWin('jiazhuang', 'http://shmp.72gs.net/app/redo/package?uid='+user._id);
		}else{
			$api.mOpenWin('jiazhuang', 'http://shmp.72gs.net/app/redo/package');
		}
	});
}

function openShop() {
	api.openWin({
		name: 'shop',
		url: "shop/main.html",
		bounces: false,
		vScrollBarEnabled: false,
		hScrollBarEnabled: false,
		reload: true,
	});
}